#![cfg_attr(feature = "axstd", no_std)]
#![cfg_attr(feature = "axstd", no_main)]

extern crate axplat_aarch64_phytium_pi;

#[cfg(feature = "axstd")]
use axstd::println;

use axhal::time;

use axhal::gpio;

#[cfg_attr(feature = "axstd", unsafe(no_mangle))]
fn main() {
    println!("println: this is gpio led demo.");

    let mut gpio_system = gpio::GpioSystem::new();
    let gpio0 = gpio_system.controller(0).unwrap();
    let p = gpio::GpioPins::p8;
    gpio0.set_pin_dir(p, true);

    let mut data = true;
    loop {
        gpio0.set_pin_data(p, data);
        println!("current data: {data}");
        data = !data;

        time::busy_wait(time::Duration::from_secs(1));
    }
}
